home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / HardwareContext.h,v < prev    next >
Text File  |  1989-06-21  |  5KB  |  286 lines

  1. head     3.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.3; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.3
  10. date     89.06.21.10.14.41;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.2;
  13.  
  14. 3.2
  15. date     89.02.20.15.34.59;  author grunwald;  state Exp;
  16. branches ;
  17. next     3.1;
  18.  
  19. 3.1
  20. date     88.12.20.13.49.52;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.3;
  23.  
  24. 1.3
  25. date     88.10.30.13.05.48;  author grunwald;  state Exp;
  26. branches ;
  27. next     1.2;
  28.  
  29. 1.2
  30. date     88.09.28.22.13.48;  author grunwald;  state Exp;
  31. branches ;
  32. next     1.1;
  33.  
  34. 1.1
  35. date     88.09.18.16.42.08;  author grunwald;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39.  
  40. desc
  41. @@
  42.  
  43.  
  44. 3.3
  45. log
  46. @*** empty log message ***
  47. @
  48. text
  49. @// This may look like C code, but it is really -*- C++ -*-
  50. // 
  51. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  52. //
  53. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  54. //
  55. #ifndef    HardwareContext_h
  56. #define    HardwareContext_h
  57. #pragma once
  58.  
  59. #include <stream.h>
  60. #include <assert.h>
  61. #include <AwesimeConfig.h>
  62.  
  63. extern const long MagicStackMarker;
  64. extern const void * UNINITIALIZED;
  65.  
  66. typedef enum {stackGrowsUp, stackGrowsDown} StackGrowthDirection;
  67. extern StackGrowthDirection StackGrows;
  68.  
  69. typedef void (*voidFuncP)();
  70.  
  71. class CpuMultiplexor;
  72. class SingleCpuMux;
  73. class MultiCpuMux;
  74. class SimulationMultiplexor;
  75.  
  76. class HardwareContext {
  77.     //
  78.     //    The following four fields are machine dependent & their order
  79.     //    should not be changed.
  80.     //
  81.     //    If the stack grows down, stackBottom < stackTop.
  82.     //
  83.     void** saved_fp;    // frame pointer
  84.     void** saved_sp;    // stack pointer
  85.     void** stackBase;    // bottom of stack
  86.     void** stackEnd;    // maximum depth of stack? (actually, a MIN value)
  87.     unsigned stackMax;    // maximum depth of stack? (actually, a MIN value)
  88.     unsigned stackSize;    // stack size in units of void*
  89.     void **stackMallocAt;
  90.     long *stackCheck;    // point to MagicStackMarker to check for corruption
  91.     unsigned checkStackLimits;
  92.     
  93.     friend class Thread;
  94.     friend class CpuMultiplexor;
  95.     friend class SingleCpuMux;
  96.     friend class MultiCpuMux;
  97.     friend class SimulationMultiplexor;
  98.     
  99.     //
  100.     //    Accessed by friend classes only
  101.     //
  102.     void switchContext(HardwareContext *to);
  103.     void magicSwitchTo(HardwareContext *to);
  104.     void **getSp();
  105.     
  106.     void **mallocAt();
  107.     void buildReturnFrame(void * returnThis, voidFuncP returnAddress);
  108.     void stackOverflow();
  109.     
  110.     //
  111.     // never allocated by anything other than friend classes
  112.     //
  113.     HardwareContext(int checked, unsigned stackSize);
  114.     
  115. public:
  116.     HardwareContext();
  117.     
  118.     long maxStackDepth();
  119.     void checkStack(int overage = 0);
  120.     void classPrintOn(ostream& strm);
  121. };
  122.  
  123. inline
  124. HardwareContext::HardwareContext()
  125. {
  126.     int NotReached = 0;
  127.     assert( NotReached );
  128. }
  129.  
  130. inline void **
  131. HardwareContext::mallocAt()
  132. {
  133.     return( stackMallocAt );
  134. }
  135.  
  136. inline ostream&
  137. operator<<(ostream& strm, const HardwareContext& ob)
  138. {
  139.     ob.classPrintOn(strm);
  140.     return strm;
  141. }
  142.  
  143.  
  144. inline long
  145. HardwareContext::maxStackDepth()
  146. {
  147.     return( long(stackMax) );
  148. }
  149.  
  150. #ifdef __GNUG__
  151. //
  152. //    Gnu G++ allows inline asm's
  153. //
  154. inline void **
  155. HardwareContext::getSp()
  156. {
  157.     void **foo;
  158. #if defined(UMAX)
  159.     asm volatile ("sprd sp,%0" : "=g" (foo));
  160. #elif defined(SUN)
  161.     asm volatile ("movel sp,%0" : "=g" (foo));
  162. #else
  163.     must define machine type
  164. #endif
  165.     return( foo );
  166. }
  167. #endif
  168.  
  169. inline void
  170. HardwareContext::checkStack(int overage)
  171. {
  172.     unsigned depth = stackBase - getSp() + overage;
  173.     if (stackMax < depth) {
  174.     stackMax = depth;
  175.     }
  176.     if ( stackMax >= stackSize || *stackCheck != MagicStackMarker ) {
  177.     stackOverflow();
  178.     }
  179. }
  180.  
  181. #endif    HardwareContext_h
  182. @
  183.  
  184.  
  185. 3.2
  186. log
  187. @Start using Gnu library heaps for schedulers
  188. @
  189. text
  190. @d9 1
  191. d11 3
  192. a13 1
  193. #include "stream.h"
  194. d23 3
  195. a25 1
  196. class HardwareContext;
  197. d29 6
  198. a34 6
  199. //
  200. //    The following four fields are machine dependent & their order
  201. //    should not be changed.
  202. //
  203. //    If the stack grows down, stackBottom < stackTop.
  204. //
  205. d44 1
  206. a44 1
  207.  
  208. d47 2
  209. d50 1
  210. a50 1
  211.  
  212. d57 1
  213. a57 1
  214.  
  215. d61 1
  216. a61 1
  217.  
  218. d66 1
  219. a66 1
  220.  
  221. d68 2
  222. a69 1
  223.  
  224. d75 7
  225. d95 1
  226. a95 1
  227.     
  228. d101 19
  229. @
  230.  
  231.  
  232. 3.1
  233. log
  234. @Steay version
  235. @
  236. text
  237. @@
  238.  
  239.  
  240. 1.3
  241. log
  242. @*** empty log message ***
  243. @
  244. text
  245. @d12 1
  246. d14 1
  247. d37 1
  248. a37 1
  249.     long *stackCheck;
  250. d52 2
  251. d55 3
  252. a57 1
  253. public:
  254. d60 2
  255. a61 1
  256.     void buildReturnFrame(void * returnThis, voidFuncP returnAddress);
  257. d63 1
  258. d86 13
  259. @
  260.  
  261.  
  262. 1.2
  263. log
  264. @*** empty log message ***
  265. @
  266. text
  267. @d1 6
  268. d19 1
  269. d39 2
  270. a40 1
  271.     friend class HardwareCpu;
  272. d48 3
  273. a52 1
  274.     ~HardwareContext();
  275. d59 5
  276. @
  277.  
  278.  
  279. 1.1
  280. log
  281. @Initial revision
  282. @
  283. text
  284. @d28 1
  285. @
  286.